// 编辑品牌保存
function saveBrand() {
    // 获取值
    var brandName = document.getElementById("carName").value
    var brandInit = document.getElementById("dealer_id").value
    var brandid = document.getElementById("brandid").value
    console.log("name" + brandName + "abab" + brandInit)
    // 后台请求
    $.ajax({
        url: 'http://192.168.0.110:8080/CarManage/updateBrandInfo',//请求后台的url
        method: 'post',//请求方式
        contentType: "application/x-www-form-urlencoded",
        data: {
            brandName: brandName,
            initial: brandInit,
            brandID: brandid
        },
        success: function (res) {
            console.log(res.msg)
            alert(res.msg)
            divset = document.getElementsByClassName("search");
            for (var i = 0; i < divset.length; i++) {
                divset[i].style.display = "inline";
            };
            divsetedit = document.getElementsByClassName("edit");
            for (var i = 0; i < divset.length; i++) {
                divsetedit[i].style.display = "none";
            };
            divsetadd = document.getElementsByClassName("editAdd");
            for (var i = 0; i < divset.length; i++) {
                divsetadd[i].style.display = "none";
            };
            location.reload();
        }
    })
}
// 新增品牌
function addBack(){
     // 返回
     divset = document.getElementsByClassName("search");
     for (var i = 0; i < divset.length; i++) {
         divset[i].style.display = "inline";
     };
     divsetedit = document.getElementsByClassName("edit");
     for (var i = 0; i < divset.length; i++) {
         divsetedit[i].style.display = "none";
     };
     divsetadd = document.getElementsByClassName("editAdd");
     for (var i = 0; i < divset.length; i++) {
         divsetadd[i].style.display = "none";
     };
}
// 新增品牌保存
function addsaveBrand() {
     // 获取值
    var brandName = document.getElementById("addbrandName").value
    var brandinitial = $('#selectOption option:selected').val();//选中的值
    console.log(brandName+brandinitial)
    $.ajax({
        url: 'http://192.168.0.110:8080/CarManage/addBrandInfo',//请求后台的url
        method: 'post',//请求方式
        contentType: "application/x-www-form-urlencoded",
        data: {
            brandName: brandName,
            initial: brandinitial
        },
        success: function (res) {
            console.log(res.msg)
            alert(res.msg)
            divset = document.getElementsByClassName("search");
            for (var i = 0; i < divset.length; i++) {
                divset[i].style.display = "inline";
            };
            divsetedit = document.getElementsByClassName("edit");
            for (var i = 0; i < divset.length; i++) {
                divsetedit[i].style.display = "none";
            };
            divsetadd = document.getElementsByClassName("editAdd");
            for (var i = 0; i < divset.length; i++) {
                divsetadd[i].style.display = "none";
            };
            location.reload();
        }
    })
}